/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.Entity.Web;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.Size;

/**
 *
 * @author user12
 */
@Entity
@Table(name = "WEB_VOTE_OPTIONS")
@NamedQueries({
    @NamedQuery(name = "WebVoteOptions.findAll", query = "SELECT w FROM VoteOption w"),
    @NamedQuery(name = "WebVoteOptions.findByOptionId", query = "SELECT w FROM VoteOption w WHERE w.voteOptionPK.optionId = :optionId"),
    @NamedQuery(name = "WebVoteOptions.findByVoteId", query = "SELECT w FROM VoteOption w WHERE w.voteOptionPK.voteId = :voteId"),
    @NamedQuery(name = "WebVoteOptions.findByOptionAr", query = "SELECT w FROM VoteOption w WHERE w.optionAr = :optionAr"),
    @NamedQuery(name = "WebVoteOptions.findByOptionEn", query = "SELECT w FROM VoteOption w WHERE w.optionEn = :optionEn"),
    @NamedQuery(name = "WebVoteOptions.findByResult", query = "SELECT w FROM VoteOption w WHERE w.result = :result")})
public class VoteOption implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected VoteOptionPK voteOptionPK;
    @Size(max = 500)
    @Column(name = "OPTION_AR")
    private String optionAr;
    @Size(max = 500)
    @Column(name = "OPTION_EN")
    private String optionEn;
    private Integer result;

    public VoteOption() {
    }

    public VoteOption(VoteOptionPK voteOptionPK) {
        this.voteOptionPK = voteOptionPK;
    }

    public VoteOption(Integer optionId, Integer voteId) {
        this.voteOptionPK = new VoteOptionPK(optionId, voteId);
    }

    public VoteOptionPK getWebVoteOptionsPK() {
        return voteOptionPK;
    }

    public void setWebVoteOptionsPK(VoteOptionPK voteOptionPK) {
        this.voteOptionPK = voteOptionPK;
    }

    public String getOptionAr() {
        return optionAr;
    }

    public void setOptionAr(String optionAr) {
        this.optionAr = optionAr;
    }

    public String getOptionEn() {
        return optionEn;
    }

    public void setOptionEn(String optionEn) {
        this.optionEn = optionEn;
    }

    public Integer getResult() {
        return result;
    }

    public void setResult(Integer result) {
        this.result = result;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (voteOptionPK != null ? voteOptionPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof VoteOption)) {
            return false;
        }
        VoteOption other = (VoteOption) object;
        if ((this.voteOptionPK == null && other.voteOptionPK != null) || (this.voteOptionPK != null && !this.voteOptionPK.equals(other.voteOptionPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.WebVoteOption[ [ webVoteOptionPK=" + voteOptionPK + " Result = " + getResult().toString() +"]";
    }
    
}
